#pragma once

#include "Character/Creature.h"
#include "Common/DropDefine.h"




class CItemBase;
class Drop : public Creature
{
	enum 
	{
		ETimer_ID_Drop = 1,
	};
public:
	Drop();
	virtual ~Drop();
public:
	virtual bool CheckAttrValue(uint32_t CANum, uint32_t attrValue) { return true; }
	virtual bool AddAttr(uint32_t CANum, int64_t attrValue, bool syn, uint64_t relationCid = 0) { return true; }
	virtual bool AddAttrCache(uint32_t CANum, int64_t attrValue, uint64_t relationCid = 0) { return true; }
	virtual void SetAttr(uint32_t CANum, int64_t attrValue, bool syn = false) {}
	virtual void SetAttrCache(uint32_t CANum, int64_t attrValue) {}

	virtual int64_t GetAttr(uint32_t CANum) { return 0; }
	virtual uint32_t GetAttrNum(uint32_t CommonAttrNum) { return 0; }
	virtual void OnTimer(uint32_t nTimerID);
public:
	virtual bool Init();
	virtual bool UnInit();
	virtual void Update(uint64_t tick);
	virtual void OnDead(CharIDType killerCid);
	virtual bool ViewFliter(Creature* pCreature, float dict);
	virtual bool IsCanBeSeen() { return !m_del; };
	virtual void GetVisibleDataToClient(CreaturesCreateData& cvData);
	virtual bool Born(CharIDType nDropCid, uint32_t sceneId, Point3<float>& bornPos,int8_t byDropType,SET_UINT64 &setTypeVal,CItemBase *pItem,uint32_t nGolds,int32_t dropInitProtect,SDropSourcePram &sourceParam,uint64_t fromWho = 0);
	virtual uint64_t delTick();
	virtual bool PlayerCanSeen(CharIDType charId);
public:
	virtual void FindCreatureInScene(Uint64Lst& clist);
public:
	//获取掉落物品
	CItemBase *GetDropItem();
	//获取掉落金币
	uint32_t GetDropGold();
	//是否可以拾取
	bool CanPickUp(CharIDType nCid);
	//设置已经拾取了
	void Pick();
	//移除
	bool Remove();
	//是否在初始保护时间内
	bool IsDuringInitProtect(uint64_t tick);
	//获取掉落来源
	const SDropSourcePram &GetDropSource();
private:
	//获取掉落可见数据
	void GetDropVisibleData(CreaturesCreateData& cvData);
	//掉落更新
	void DropUpdate(uint64_t tick);
	//获取剩余时间
	uint64_t GetLeftTime();
	//获取剩余时间
	uint64_t GetLeftTime(uint64_t tick);
	//是否是杀戮之石
	bool IsKillStone();
	//是否是神之遗骸
	bool IsCurseFall();
	//是否是阵营旌旗
	bool IsCampFlag();
	//生存时间
	int32_t SurviveSec();
	//是否再保护时间内
	bool IsDuringProtect(uint64_t tick);
protected:
	CItemBase *m_pItem;			//掉落物品
	int32_t   m_itemSubType;	//掉落物品子类型
	uint32_t  m_nGold;			//掉落金币（掉落金币必须要大于0,并且金币和物品只有一个有值）
	uint64_t  m_nDropTime;		//掉落时间（tick）
	uint64_t  m_nDropSec;		//掉落时间秒数
	int8_t    m_byDropType;		//掉落类型
	uint32_t  m_nInitProtect;	//初始保护时间
	SDropSourcePram m_source;	//来源
	uint64_t  m_delTick;
	uint64_t  m_fromWho;		//从谁身上掉落
	SET_UINT64 m_setTypeVal;	//掉落类型相关的数值 (独立掉落和个人掉落表示生物的cid,队伍掉落表示 队伍ID,公共掉落为0)
	bool m_del;
};
